package user;

import opreation.IOperation;
import opreation.impl.*;

import java.util.Scanner;

/**
 * 普通用户类
 * @Author Stark
 * @Date 2022/1/23 17:56
 */
public class NormalUser extends User{
    private Scanner scanner = new Scanner(System.in);
    public NormalUser(String name){
        this.name = name;
        this.operations = new IOperation[]{
                //显示书籍接口
                new DisplayOperation(),
                //查询书籍的接口
                new FindOperation(),
                //借阅书籍
                new BorrowOperation(),
                //归还书籍
                new ReturnOperation()
        };
    }

    //菜单的返回值就是用户输入的值
    @Override
    public int menu() {
        System.out.println("=======================================");
        System.out.println("欢迎" + this.name + "登录图书管理系统");
        System.out.println("1.显示当前的书籍列表");
        System.out.println("2.查询书籍");
        System.out.println("3.借阅书籍");
        System.out.println("4.归还书籍");
        System.out.println("-1.退出");
        System.out.println("=======================================");
        System.out.print("请输入您的选择:");
        int choice = scanner.nextInt();
        if (choice == -1) {
            // 关闭输入
            scanner.close();
        }
        return choice;
    }
}
